package day07_collections_map.com.itheima.d2_collections;

import java.util.ArrayList;
import java.util.Collections;

public class CollectionsTest1 {
    public static void main(String[] args) {
        ArrayList<String> names = new ArrayList<>();
        Collections.addAll(names, "张三", "王五", "赵六", "田七");
        System.out.println("names = " + names);

        Collections.shuffle( names);
        System.out.println("names = " + names);

        ArrayList<Student> students = new ArrayList<>();
        Student s1 = new Student("张三", 18, 180);
        Student s2 = new Student("王五", 19, 180);
        Student s3 = new Student("赵六", 20, 180);
        Collections.addAll(students, s1, s2, s3);

        Collections.sort(students);
        System.out.println("students = " + students);

        Collections.sort(students,((o1, o2) -> {
            return o1.getAge() - o2.getAge();
        }));
        System.out.println("students = " + students);

    }
}
